package c1762;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class D {
    static Scanner cin = new Scanner(new BufferedInputStream(System.in));//大量输入优化版本
    static PrintWriter cout = new PrintWriter(new BufferedOutputStream(System.out));//大量输出优化版本
    static PrintWriter cerr = new PrintWriter(System.err, true);//开启调试模式,一般输出量不大，不需要buffered

    public static void main(String[] args) {
        //TODO AOJ开启你的ACM传奇人生
        int m = cin.nextInt();
        int n = cin.nextInt();
        int[] f = new int[m];
        int[] g = new int[n];
        for (int i = 0; i < m; i++) f[i] = cin.nextInt();
        for (int i = 0; i < n; i++) g[i] = cin.nextInt();
        Arrays.sort(f);
        Arrays.sort(g);
        int best = Integer.MAX_VALUE;
        for (int x : f)
            for (int y : g) {
                best = Math.min(best, Math.abs(x - y));
            }
        cout.println(best);
        cin.close();//关闭输入流
        cout.close();//关闭输出流，这是必须的，否则一般不会自动刷新缓冲区
    }
}